home *** CD-ROM | disk | FTP | other *** search
/ 9-Digit Zip Code Directory / 9-Digit Zip Code Directory (American Business Information) (ABIZIP-12).ISO / z4src.zip / E4EXPR.H < prev    next >
C/C++ Source or Header  |  1993-03-03  |  9KB  |  290 lines

  1. /* e4expr.h   (c)Copyright Sequiter Software Inc., 1990-1993.  All rights reserved. */
  2.  
  3. #define   E4MAX_PARMS          3
  4. #define   E4MAX_STACK_ENTRIES 20
  5.  
  6. typedef void S4OPERATOR(void) ;
  7.  
  8. struct TOTAL4st ;
  9.  
  10. typedef struct E4INFO_st
  11. {
  12.    FIELD4 *field_ptr ;
  13.    char *p1 ;
  14.    int   len ;         /* Length */
  15.    int   num_entries ; /* Number of entries in sub-expression */
  16.    int   num_parms ;
  17.    int   result_pos ;  /* The position in the result array for result. */
  18.    int   i1 ;          /* Could be constant position. 'i1' and 'result_pos'
  19.                        and 'function_i' and 'function'
  20.                        must be at last position due to memcmp() in e4is_tag() */
  21.    int   function_i ;
  22.    S4OPERATOR *function ;
  23. } E4INFO ;
  24.  
  25. typedef struct
  26. {
  27.    void     (S4PTR *function_ptr)() ;
  28.    char    *name ;
  29.    short    code ;
  30.    char     name_len ;
  31.    char     priority ;
  32.    char     return_type ;
  33.    signed char  num_parms ;  /* -1 means that the number is flexible */
  34.    char     type[E4MAX_PARMS] ;   /* Parameter types */
  35. }  E4FUNCTIONS ;
  36.  
  37. typedef struct
  38. {
  39.    char    S4PTR *ptr ;     /* The original string */
  40.    int      pos, len ;      /* Source expression position and length */
  41. } S4SCAN ;
  42.  
  43. typedef struct
  44. {
  45.    char S4PTR *ptr ;
  46.    unsigned int   pos, len ;
  47.    int   do_extend ;
  48.    CODE4 S4PTR *code_base ;
  49. } S4STACK ;
  50.  
  51. typedef struct
  52. {
  53.    EXPR4   expr ;
  54.    S4STACK  constants ;
  55.    S4SCAN   scan ;          /* Character Expression */
  56.    S4STACK  op ;            /* Operation stack */
  57.    CODE4  S4PTR *code_base ;
  58. } E4PARSE ;
  59.  
  60. typedef struct
  61. {
  62.    LINK4 link ;
  63.    EXPR4 *expr ;
  64.    struct TOTAL4st *total ; /* If calculation is for a total. */
  65.    char    name[20] ;
  66.    int     cur_result_pos ;
  67. } EXPR4CALC ;
  68.  
  69. extern char *expr4buf ;        /* Working memory */
  70. extern unsigned expr4buf_len ; /* Length, e4execute() assumes length long enough */
  71.  
  72. extern char **expr4 ;          /* Expression Parms; Points to next parm to be placed */
  73.  
  74. extern EXPR4 *expr4ptr ;     /* Points to expression being evaluated */
  75. extern E4INFO *expr4info_ptr ;
  76. extern char   *expr4constants ; /* Points to constant info */
  77.  
  78. extern E4FUNCTIONS  v4functions[] ;
  79.  
  80. /* Types normally used for Function/Operator parameters and returns */
  81. #define  r4date      'D'
  82. #define  r4date_doub 'd'
  83. #define  r4log       'L'
  84. #define  r4num       'N'
  85. #define  r4num_doub  'n'
  86. #define  r4str       'C'
  87. #define  r4memo      'M'
  88.  
  89. /* Codes for Immediate Data in Compile String */
  90. #define  E4FIELD_STR        0
  91. #define  E4FIELD_STR_CAT    1
  92. #define  E4FIELD_LOG        2
  93. #define  E4FIELD_DATE_D     3
  94. #define  E4FIELD_DATE_S     4
  95. #define  E4FIELD_NUM_D      5
  96. #define  E4FIELD_NUM_S      6
  97. #define  E4FIELD_MEMO       7
  98.  
  99. #define  E4DOUBLE           8
  100. #define  E4STRING           9
  101.  
  102. #define  E4LOG_LOW         10
  103. #define  E4LOG_HIGH        13
  104.  
  105. #define  E4LAST_FIELD       7
  106.  
  107. #define  E4FIRST_LOG       10  /* Range of Logical Operators */
  108. #define  E4LAST_LOG        14
  109. #define  E4FIRST_OPERATOR  15  /* Range of Other Operators */
  110. #define  E4LAST_OPERATOR   51
  111. #define  E4COMPARE_START   26
  112. #define  E4COMPARE_END     46
  113. #define  E4FIRST_FUNCTION  52  /* Start of the List of Functions */
  114.  
  115. #define E4OR 15
  116. #define E4AND 16
  117. #define E4CONCATENATE 17
  118. #define E4CONCAT_TRIM 18
  119. #define E4CONCAT_TWO 22
  120. #define E4EQUAL 26
  121. #define E4NOT_EQUAL 30
  122. #define E4GREATER_EQ 35
  123. #define E4LESS_EQ 38
  124. #define E4GREATER 41
  125. #define E4LESS 44
  126. #define E4DEL 52
  127. #define E4STR 53
  128. #define E4SUBSTR 54
  129. #define E4TIME 55
  130. #define E4UPPER 56
  131. #define E4DTOS 57
  132. #define E4DTOC 59
  133. #define E4TRIM 61 
  134. #define E4LTRIM 62
  135. #define E4LEFT 63
  136. #define E4IIF 64
  137. #define E4STOD 68
  138. #define E4CTOD 69
  139. #define E4DELETED 77
  140. #define E4RECCOUNT 78
  141. #define E4RECNO 79
  142. #define E4CALC_FUNCTION 81
  143. #define E4TOTAL 82
  144. #define E4DESCEND_STR 84
  145.  
  146. #define  E4DONE              -2
  147. #define  E4NO_FUNCTION       -3
  148. #define  E4COMMA             -4
  149. #define  E4L_BRACKET         -5
  150. #define  E4ANOTHER_PARM      -6
  151.  
  152. /* Interface Functions */
  153. #ifdef __cplusplus
  154. extern "C" {
  155. #endif
  156. double  S4FUNCTION expr4double( EXPR4 S4PTR * ) ;
  157. int     S4FUNCTION expr4double2( EXPR4 S4PTR *, double * ) ;
  158. void    S4FUNCTION expr4free( EXPR4 S4PTR * ) ;
  159. int     S4FUNCTION expr4len( EXPR4 S4PTR * ) ;
  160. int     S4FUNCTION expr4key( EXPR4 S4PTR *, char S4PTR * S4PTR * ) ;
  161. int     S4FUNCTION expr4key_convert( EXPR4 S4PTR *, char S4PTR * S4PTR *, int, int ) ;
  162. int     S4FUNCTION expr4key_len( EXPR4 S4PTR * ) ;
  163. EXPR4 S4PTR *S4FUNCTION expr4parse( DATA4 S4PTR *, char S4PTR * ) ;
  164. char S4PTR *S4FUNCTION expr4source( EXPR4 S4PTR * ) ;
  165. int     S4FUNCTION expr4type( EXPR4 S4PTR * ) ;
  166. int     S4FUNCTION expr4true( EXPR4 S4PTR * ) ;
  167. long    S4FUNCTION e4long( EXPR4 S4PTR * ) ;
  168. int     S4FUNCTION e4to_key( EXPR4 S4PTR *, char S4PTR * S4PTR * ) ;
  169. int     S4FUNCTION expr4vary( EXPR4 S4PTR *, char S4PTR * S4PTR * ) ;
  170. #ifdef __cplusplus
  171. }
  172. #endif
  173.  
  174. /* Parsing Functions */
  175. E4INFO *e4function_add( EXPR4 *, int ) ;
  176. int e4add_constant( E4PARSE *, int, void *, unsigned ) ;
  177.  
  178. int    e4get_operator( E4PARSE S4PTR *, int S4PTR * ) ;
  179. int    S4FUNCTION e4lookup( char S4PTR *,int,int,int ) ;
  180. int    expr4parse_expr( E4PARSE S4PTR * ) ;
  181. int    expr4parse_function( E4PARSE S4PTR *, char S4PTR *,int ) ;
  182. int    expr4parse_value( E4PARSE S4PTR * ) ;
  183. int    expr4true_check( E4PARSE S4PTR * ) ;
  184.  
  185. char   s4scan_char( S4SCAN S4PTR * ) ;
  186. void   s4scan_init( S4SCAN S4PTR *, char S4PTR * ) ;
  187. char   s4scan_pop( S4SCAN S4PTR *) ; /* Returns current char and goes to the next */
  188. int    s4scan_search( S4SCAN S4PTR *, char ) ; /* Returns # of characters scanned */
  189. int    s4scan_range( S4SCAN S4PTR *, int, int ) ;
  190.  
  191. int    s4stack_cur( S4STACK S4PTR * ) ;
  192. int    s4stack_pop( S4STACK S4PTR * ) ;
  193. int    s4stack_push_int( S4STACK S4PTR *, int ) ;
  194. int    s4stack_push_str( S4STACK S4PTR *, void S4PTR *, int ) ;
  195.  
  196. /* Execute Functions */
  197. void e4add( void ) ;
  198. void e4add_date( void ) ;
  199. void e4and( void ) ;
  200. void e4calc_function( void ) ;
  201. void e4calc_total( void ) ;
  202. void e4concat_special( char ) ;
  203. void e4concat_trim( void ) ;
  204. void e4concat_two( void ) ;
  205. void e4contain( void ) ;
  206. void e4copy_constant( void ) ;
  207. void e4field_copy( void ) ;
  208. void e4copy_parm( void ) ;
  209. void e4ctod( void ) ;
  210. void e4date( void ) ;
  211. void e4day( void ) ;
  212. void e4day_doub( void ) ;
  213. void e4del( void ) ;
  214. void e4deleted( void ) ;
  215. void e4divide( void ) ;
  216. void e4dtoc( void ) ;
  217. void e4dtoc_doub( void ) ;
  218. void e4dtos_doub( void ) ;
  219. void e4equal( void ) ;
  220. void e4false( void ) ;
  221. void e4field_date_d( void ) ;
  222. void e4field_log( void ) ;
  223. void e4field_memo( void ) ;
  224. void e4field_num_d( void ) ;
  225. void e4greater( void ) ;
  226. void e4greater_doub( void ) ;
  227. void e4greater_eq( void ) ;
  228. void e4greater_eq_doub( void ) ;
  229. void e4iif( void ) ;
  230. void e4less( void ) ;
  231. void e4less_doub( void ) ;
  232. void e4less_eq( void ) ;
  233. void e4less_eq_doub( void ) ;
  234. void e4ltrim( void ) ;
  235. void e4month( void ) ;
  236. void e4month_doub( void ) ;
  237. void e4multiply( void ) ;
  238. void e4new_function( void ) ;
  239. void e4nop( void ) ;
  240. void e4not( void ) ;
  241. void e4not_equal( void ) ;
  242. void e4or( void ) ;
  243. void e4field_add( void ) ;
  244. void e4parm_remove( void ) ;
  245. void e4power( void ) ;
  246. void e4reccount( void ) ;
  247. void e4recno( void ) ;
  248. void e4stod( void ) ;
  249. void e4str( void ) ;
  250. void e4sub( void ) ;
  251. void e4sub_date( void ) ;
  252. void e4substr( void ) ;
  253. void e4time( void ) ;
  254. void e4trim( void ) ;
  255. void expr4true_function( void ) ;
  256. void e4upper( void ) ;
  257. void e4val( void ) ;
  258. void e4year( void ) ;
  259. void e4year_doub( void ) ;
  260. void e4pageno( void ) ;
  261. #ifdef S4CLIPPER
  262.    void e4descend_str( void ) ;
  263.    void e4descend_num_doub( void ) ;
  264.    void e4descend_num_str( void ) ;
  265.    void e4descend_date_doub( void ) ;
  266. #endif
  267.  
  268.  
  269. #ifdef __cplusplus
  270.    extern "C" {
  271. #endif
  272.  
  273. /* Relate Module and Report Writer Functions */
  274. int S4FUNCTION expr4compare_flip( int ) ;
  275. int S4FUNCTION expr4execute( EXPR4 *, int, void ** ) ;
  276. void S4FUNCTION expr4functions(E4FUNCTIONS **) ;
  277.  
  278. EXPR4 S4PTR *S4FUNCTION expr4calc_parse( DATA4 S4PTR *, char S4PTR * ) ;
  279. void    S4FUNCTION expr4calc_delete( EXPR4CALC * ) ;
  280. void    S4FUNCTION expr4calc_reset( CODE4 * ) ;
  281. void    S4FUNCTION expr4calc_massage( EXPR4CALC * );
  282. EXPR4CALC *S4FUNCTION expr4calc_create( CODE4 *, EXPR4 *, char * ) ;
  283. EXPR4CALC *S4FUNCTION expr4calc_lookup( CODE4 *, char *, unsigned ) ;
  284. int     S4FUNCTION expr4calc_name_change( EXPR4 **, char *, char * ) ;
  285. void    S4FUNCTION expr4calc_result_pos( EXPR4CALC *, int ) ;
  286.  
  287. #ifdef __cplusplus
  288.    }
  289. #endif
  290.